package com.xiaoKe.zhonghzu.ui.login;

import android.content.Context;
import android.content.Intent;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.xiaoKe.zhonghzu.R;
import com.xiaoKe.zhonghzu.global.tool.SPUtils;
import com.xiaoKe.zhonghzu.ui.WebActivity;
import com.xiaoKe.zhonghzu.ui.onClick.NoDoubleClickListener;

/**
 * @ProjectName : xiaoke-pad-zhongzhu
 * @Author : Shijingna
 * @Time : 2024/12/18 16:15
 * @Description : 文件描述
 */
public class ViewLogin extends LinearLayout {
    public ViewLogin(Context context) {
        super(context);
    }

    public ViewLogin(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ViewLogin(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    TextView agreement1, agreement2, agreement3;
    private ImageView imgConsent;
    boolean aBoolean;

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        imgConsent = findViewById(R.id.imgConsent);
        agreement1 = findViewById(R.id.agreement1);
        agreement2 = findViewById(R.id.agreement2);
        agreement3 = findViewById(R.id.agreement3);
        NoDoubleClickListener noDoubleClickListener = new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View view) {
                switch (view.getId()) {
                    case R.id.agreement1:
                    case R.id.agreement2:
                    case R.id.agreement3:
                        getContext().startActivity(new Intent(getContext(), WebActivity.class).putExtra("url", "http//www.baidu.com").putExtra("title", "协议"));
                        break;
                }
            }
        };
        agreement1.setOnClickListener(noDoubleClickListener);
        agreement2.setOnClickListener(noDoubleClickListener);
        agreement2.setOnClickListener(noDoubleClickListener);
        imgConsent.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                imgConsent.setImageResource(!aBoolean ? R.mipmap.ic_xz4 : R.mipmap.ic_wxz4);
                aBoolean = !aBoolean;
                SPUtils.putBoolean("imgConsent",aBoolean);
            }
        });

    }
}
